package com.shelpe.services.lexicon.feign;

import java.io.IOException;
import java.lang.reflect.Type;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.cloud.netflix.feign.support.SpringDecoder;

import feign.FeignException;
import feign.Response;

public class SimbaDecoder extends SpringDecoder {

	public SimbaDecoder(ObjectFactory<HttpMessageConverters> messageConverters) {
		super(messageConverters);
	}

	@Override
	public Object decode(Response response, Type type) throws IOException, FeignException {
		ExeceptionDecoder exDecoder = type.getClass().getAnnotation(ExeceptionDecoder.class);
		if(exDecoder != null){
			response.body();
		}
		return super.decode(response, type);
	}

}
